package com.zhu.mqsms.controller;

import com.zhu.mqsms.service.SmsSenderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 *
 *
 * @param
 * @return
 * @author zhuwanyi
 * @create 2024/12/10
 **/

@RestController
@Api(tags = "短信发送服务")
@RequestMapping("/sms")
public class SmsController {

    @Autowired
    private SmsSenderService smsSenderService;

    /**
     * 通过mq发送短信验证码
     * @param phoneNumber
     */
    @ApiOperation(value = "通过mq发送短信验证码")
    @RequestMapping(value="/sendsmsbymq/{phoneNumber}",method= RequestMethod.POST)
    public String sendCode(@PathVariable String phoneNumber ){
        smsSenderService.sendSmsAsync(phoneNumber);
        System.out.println("手机号：" +phoneNumber+";发送短信验证码成功");
        return "短信发送任务已提交，将异步发送。";
    }
}
